import { useState } from "react";
import axios from 'axios';

function Charset() {
    const [data, setData] = useState("");
    // 事件处理函数
    const onClickHandler = () => {
        axios.get("http://localhost:9090/tb/d/exec3", {

        }).then(response => {
            setData(response.data.name);
        }).catch(error => {
            console.error('Error >> ', error)
        });
    };
    // 事件处理函数
    const clearData = () => {
        setData("");
    }

    return (
        <div>
            <span>{data}</span>
            <button alt="wwww" title="oooo" onClick={onClickHandler}>GetApiData</button>
            <button onClick={clearData}>Clear</button>
        </div>
    )
}


export default Charset;
/**
 * 有状态组件
 */